<?php

// +----------------------------------------------------------------------
// | Category api控制器
// +----------------------------------------------------------------------
// | @author fancsen
// +----------------------------------------------------------------------

/**
 * Category api控制器
 * @author fancsen
 */


namespace app\api\controller\v1;

use app\api\model\Category as CategoryModel;
use app\common\lib\exception\ApiException;
use app\api\validate\IDMustBePostiveInt;

class Category
{
   
    /**
    * 获取专题推荐
    * @http get  /category/all 
    * @return array 返回一组category
    */
    public function getAllCategories()
    {
        $categorys = CategoryModel::all(function($query){
            $query->with('topicImg')->order('sort');
        });

        if($categorys->isEmpty()){
            throw new ApiException('请求指定的类目不存在',404,60000);
        }
        return show(config('api.success_status'),'ok',$categorys);
    }

    
    

}